package com.rocket.bedroom.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rocket.bedroom.dao.GradeDao;
import com.rocket.bedroom.pojo.GradeEntity;
import com.rocket.bedroom.service.IGradeService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @Author: 周毅
 * @ClassName:
 * @Description: TODO
 * @Date: Create in 17:43 2020/5/6
 * @ModifyBy:
 */
@Service
public class GradeServiceImpl extends ServiceImpl<GradeDao, GradeEntity> implements IGradeService {

    /**
     * 判断年纪名称是否存在重复
     * @param gradeName
     * @return
     */
    @Override
    public int hasGradeName(String gradeName) {
        LambdaQueryWrapper<GradeEntity> lambdaQuery = Wrappers.<GradeEntity>lambdaQuery();
        if (!StringUtils.isEmpty(gradeName)) {
            lambdaQuery.eq(GradeEntity::getGradeName, gradeName);
        }
        return super.count(lambdaQuery);
    }
}
